﻿using HMaker.Utils;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace HMaker.Controls
{
    /// <summary>
    /// 矩形形状控件
    /// </summary>
    public class ShapeRectangle : ShapeControl
    {
        public ShapeRectangle(OriginPos origin = null) : base(origin)
        {
            Location = Point.Empty;
            Size = new Size(100, 50);
        }

        public ShapeRectangle(Point centerPos, Size size, OriginPos origin = null) : base(origin)
        {
            Size = size;
            CenterPos = centerPos;

        }
        public ShapeRectangle(Rectangle rect, OriginPos origin = null) : base(origin)
        {
            Size = rect.Size;
            Location = rect.Location;

        }

        public override KeyValuePair<string, string> ShapeDescription => new KeyValuePair<string, string>("SHAPERECTANGLE", $"{Util.MakeString(IsBound ? RelativeCenterPos : CenterPos)},{Util.MakeString(Size)}");

        public override ShapeControl Clone()
        {
            return new ShapeRectangle(Bounds, OriginPos);
        }

        protected override GraphicsPath OnDrawRegion()
        {
            return null;
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.FillRectangle(ForeBrush, new Rectangle(Point.Empty, Size));
            base.OnPaint(e);
        }
    }

}
